home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / export / history / common / historyscripting.c < prev   
Encoding:
C/C++ Source or Header  |  1996-09-30  |  1.9 KB  |  83 lines

  1. /*
  2.     File: HistoryScripting.c
  3.  
  4.     Copyright (c) 1994-6, Adobe Systems Incorporated.
  5.     All rights reserved.
  6.  
  7.     C source file for scripting functions for Shape example.
  8. */
  9.  
  10. #include "History.h"
  11.  
  12. /*****************************************************************************/
  13.  
  14. /* Checks the parameters against scripting-returned parameters, if any, and
  15.    updates our parameters to match ones given to us by the scripting system. */
  16.  
  17. Boolean ReadScriptParams (GPtr globals)
  18. {
  19.     PIReadDescriptor            token = NULL;
  20.     DescriptorKeyID                key = NULLID;
  21.     DescriptorTypeID            type = NULLID;
  22.     OSType                        x = typeNull;
  23.     DescriptorKeyIDArray        array = { NULLID };
  24.     int32                        flags = 0;
  25.     OSErr                        stickyError = noErr;
  26.     Boolean                        returnValue = true;
  27.     
  28.     if (DescriptorAvailable())
  29.     { /* playing back.  Do our thing. */
  30.         token = OpenReader(array);
  31.         if (token)
  32.         {
  33.             while (PIGetKey(token, &key, &type, &flags))
  34.             {
  35.                 switch (key)
  36.                 {
  37.                     // read globals here
  38.                 }
  39.             }
  40.  
  41.             stickyError = CloseReader(&token); // closes & disposes.
  42.                 
  43.             if (stickyError)
  44.             {
  45.                 if (stickyError == errMissingParameter) // missedParamErr == -1715
  46.                     ;
  47.                     /* (descriptorKeyIDArray != NULL)
  48.                        missing parameter somewhere.  Walk IDarray to find which one. */
  49.                 else
  50.                     gResult = stickyError;
  51.             }
  52.         }
  53.         
  54.         returnValue = PlayDialog();
  55.         /* return TRUE if want to show our Dialog */        
  56.     }
  57.     
  58.     return returnValue;
  59. }
  60.         
  61. /*****************************************************************************/
  62.  
  63. /* Writes our parameters to the scripting system. */
  64.  
  65. OSErr WriteScriptParams (GPtr globals)
  66. {
  67.     PIWriteDescriptor            token = nil;
  68.     OSErr                        gotErr = noErr;
  69.             
  70.     if (DescriptorAvailable())
  71.     { /* recording.  Do our thing. */
  72.         token = OpenWriter();
  73.         if (token)
  74.         {
  75.             // write keys here
  76.             
  77.             gotErr = CloseWriter(&token); /* closes and sets dialog optional */
  78.             RecordInfo = plugInDialogRequired; // override to always force dialog
  79.             /* done.  Now pass handle on to Photoshop */
  80.         }
  81.     }
  82.     return gotErr;
  83. }